//
//  ViewController.m
//  DMCollectionView
//
//  Created by Apple on 2017/7/4.
//  Copyright © 2017年 Xwg. All rights reserved.
//

#import "ViewController.h"
#import "DMCollectionCell.h"
#import "DMCircleScrollView.h"

@interface ViewController ()

@property (nonatomic, strong) DMCircleScrollView *scrollView;
@end

@implementation ViewController

- (DMCircleScrollView *)scrollView {
    if (!_scrollView) {
        _scrollView = [[DMCircleScrollView alloc] initWithFrame:CGRectMake(40, 200, self.view.bounds.size.width - 80, 200)];
        _scrollView.itemWidth = 150;
//        _scrollView.itemAspectRatio = 1;
        _scrollView.itemSpacing = 16;
        _scrollView.backgroundColor = [UIColor cyanColor];
    }
    return _scrollView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSString *ID = NSStringFromClass([DMCollectionCell class]);
    [self.scrollView registerWithNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
    _scrollView.numberOfItems = 15;
    [self.view addSubview:self.scrollView];
    
    
    
    [self handleScrollViewFunctions];
}


- (void)handleScrollViewFunctions {
    self.scrollView.setupCellForItemAtIndex = ^(UICollectionViewCell * _Nonnull cell, NSInteger item, NSInteger index) {
        DMCollectionCell *myCell = (DMCollectionCell *)cell;
        myCell.tempIndex = item;
        myCell.index = index;
    };
    
    self.scrollView.didSelectItem = ^(NSInteger item, NSInteger index) {
        NSLog(@"%ld %ld", item, index);
    };
}

@end
